unit basicio_field;

{$mode objfpc}{$H+}

{
  stores all informations about a singe field on the playfield
}

interface

uses
  Classes, SysUtils, fgl;

type
  TResKind = (RK_Wood,RK_Dirt,RK_Sheeps,RK_Wheat,RK_Ore,PK_None);

  TFieldPosition = record
    x,y: integer
  end;

  { TField }

  TField = class
    private
      FDice: integer;
      FKind: TResKind;
      FX: integer;
      FY: integer;
      function GetPosition: TFieldPosition;
    public
      property X: integer read FX;
      property Y: integer read FY;
      property kind: TResKind read FKind write FKind;
      property position: TFieldPosition read GetPosition;
      property dice: integer read FDice write FDice;
    public
      constructor Create(AX,AY: Integer);
      destructor Destroy; override;
  end;

  TFieldList  = specialize TFPGObjectList<TField>;

operator = (a,b: TFieldPosition): boolean;
function FieldPositionToString(APos: TFieldPosition): String;

implementation

operator=(a, b: TFieldPosition): boolean;
begin
  result := (a.x=b.x) and (a.y=b.y);
end;

function FieldPositionToString(APos: TFieldPosition): String;
begin
  result := 'x:'+Inttostr(APos.x)+' y:'+inttostr(APos.Y);
end;

{ TField }

function TField.GetPosition: TFieldPosition;
begin
  result.x := FX;
  result.y := FY;
end;

constructor TField.Create(AX, AY: Integer);
begin
  inherited Create;
  FX := AX;
  FY := AY;
end;

destructor TField.Destroy;
begin
  inherited Destroy;
end;

end.

